package com.example.musicplayer.ui;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.widget.Toast;

import com.example.musicplayer.service.MusicServiceStub;

public class HeadphoneUnPlugIntent extends BroadcastReceiver {

	@Override
	public void onReceive(Context context, Intent intent) {
		if(intent.getAction().equals(android.media.AudioManager.ACTION_AUDIO_BECOMING_NOISY)){
			Intent pauseMusicIntent = new Intent(context, MusicServiceStub.class);
			pauseMusicIntent.setAction(MusicServiceStub.ACTION_PAUSE);
			context.startService(pauseMusicIntent);
		Toast.makeText(context, "Headphones Unplugged, music paused", Toast.LENGTH_SHORT).show();
		}		
	}

}
